<?php

class prize_mdl extends Model
{
    public static $table = 'get_prize';


    public function save_prize($tb_uid, $nick, $prize){
        $tags = $this->dbh->insert(self::$table, array(
            'openid' => $tb_uid,
            'nick' => $nick,
            'prize' => $prize,
            'create_time' => date('Y-m-d H:i:s')
        ));
        $rs = $this->dbh->insert_id();

        $sql = 'SELECT *
					FROM '.self::$table.'
					WHERE id = '.$rs
        ;
        $r = $this->dbh->get_one($sql);

        return $r;
    }


    public function list_prize_day($tb_uid){
        $r = '';
        if(!empty($tb_uid)){
            $sql = 'SELECT *
					FROM '.self::$table.'
					WHERE to_days(create_time) = to_days(now()) 
					AND openid = "'.$tb_uid.'"'
            ;
            $r = $this->dbh->get_all($sql);
        }
        return $r;
    }

}